<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>店铺销售报表分析</title>
        <link href="../common/css/style1.css" rel="stylesheet" type="text/css" />
    	<link href="../common/css/ui.jqgrid.css" rel="stylesheet" type="text/css" />
    	<link href="../common/js/dp/css/jquery-ui-1.8.6.custom.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../common/js/jquery-1.9.1.min.js"></script>
        <script type="text/javascript" src="../common/js/jquery-ui.js"></script>
        <script type="text/javascript" src="../common/js/common.js"></script>
        <script type="text/javascript" src="../common/js/dp/js/jquery-ui-timepicker-addon.js"></script>
        <script type="text/javascript" src="../common/js/dp/js/ui.datepicker-zh-cn.js"></script>
        <script type="text/javascript" src="../common/js/datetime.js"></script>
        <script src="../common/js/jquery.fileDownload.js"></script>
        <script src="../common/js/view/salesAnalysis_report_week_search.js"></script>
 
 		<script type="text/javascript">
        function ShowMenu(id) {
            var className = document.getElementById('menu' + id).className;
            if(className.indexOf('curr')==-1)
                document.getElementById('menu' + id).className = 'mouseover';
            else
                document.getElementById('menu' + id).className = 'curr mouseover';
            document.getElementById('ul'+id).style.display = 'block';
        }
        function HideMenu(id) {
            var className = document.getElementById('menu' + id).className;
            if (className.indexOf('curr') == -1)
                document.getElementById('menu' + id).className = '';
            else
                document.getElementById('menu' + id).className = 'curr';
            document.getElementById('ul' + id).style.display = 'none';
        }
        var oldOld = null;
        function ShowMenuDd(obj) {
            if (oldOld == obj) return;
            if (oldOld != null) {
                oldOld.className = '';
            }
            obj.className = 'visible';
            oldOld = obj;
        }

        var speed3 = 10; //速度数值越大速度越慢
        var maxWidth = 0;
        window.onload = function () {
            maxWidth = document.getElementById("divScrollCommend").scrollWidth;
            document.getElementById("tdScroll2").innerHTML = document.getElementById("tdScroll1").innerHTML;
            var MyMar = setInterval(Marquee, speed3);
            document.getElementById("divScrollCommend").onmouseover = function () { clearInterval(MyMar) }
            document.getElementById("divScrollCommend").onmouseout = function () { MyMar = setInterval(Marquee, speed3) }
        }

        function Marquee() {
            var left = parseInt(document.getElementById("divScrollCommend").style.left);
            if (left + maxWidth == 0) {
                left = 0;
            }
            else {
                left--;
            }
            document.getElementById("divScrollCommend").style.left = left + 'px';
        }
        function query(){
        	var datas = {fun:'query',date_type:getRadioVal('time')};
        	var oDate = $('#date_range');
			oDate.val($.trim(oDate.val()));
			var tok = oDate.val().split(' ~ ');
			if(oDate.val()==''){
				alert('请输入期间');oDate.focus();return;
			}else if((tok.length!=2 || !isDateStr(tok[0]) || !isDateStr(tok[1]))){
				alert('日期有误');oDate.focus();return;
			}else if(compareDateStr(tok[0], tok[1])<0){
				alert('结束日期应大于开始日期');oDate.focus();return;
			}else if(datas['date_type']=='udf' && !isDateStr($('#begin_time').val())){
				alert('开始日期有误');$('#begin_time').focus();return;
			}else if(datas['date_type']=='udf' && !isDateStr($('#end_time').val())){
				alert('结束日期有误');$('#end_time').focus();return;
			}else if(datas['date_type']=='udf' && compareDateStr($('#begin_time').val(), $('#end_time').val())<0){
				alert('结束日期应大于开始日期');$('#end_time').focus();return;
			}
			var beginTime = $("#beginTime").val(tok[0]).val();
			var endTime = $("#endTime").val(tok[1]).val();
			var dateType = $("#timeType").val(getRadioVal("time")).val();
			document.location.href='<%=basePath%>data/excel_export!exportSalesReport.action?dateType='+dateType+'&beginTime='+beginTime+'&endTime='+endTime;
        }
        
        function exportSalesReport(){
			var chooseTime = $("#chooseTime").val();
			var compareYear = $("#compareYear").val();
			var dateType = $('input[name=dateType]:checked').val();
			var beginTime =  $("#chooseBeginTime").val();
			var endTime =  $("#chooseEndTime").val();
		
			if(dateType!='lastCustom'){
				beginTime=chooseTime;
				endTime=chooseTime;
				if(chooseTime==''){
					alert('请选择时间');
					return;
				}
			}else{
				if(beginTime==''||endTime==''){
					alert('请选择时间');
					return;
				}
			}
		
		//	alert("chooseTime:"+chooseTime);
		//	alert("compareYear:"+compareYear);
		//	alert("dateType:"+dateType);
		//	alert("beginTime:"+beginTime);
		//	alert("endTime:"+endTime);
			document.location.href='<%=basePath%>data/excel_export!exportSalesReport.action?dateType='+dateType+'&beginTime='+beginTime+'&endTime='+endTime+'&compareYear='+compareYear;
		}
		
		function showTimeArea(dateType){
			if(dateType!='lastCustom'){
				document.getElementById("customTimeArea").style.display='none';
				document.getElementById("compareYearArea").style.display='none';
				document.getElementById("chooseTimeArea").style.display='';
			}else{
				document.getElementById("customTimeArea").style.display='';
				document.getElementById("compareYearArea").style.display='';
				document.getElementById("chooseTimeArea").style.display='none';
			}
			
		}
        
    </script>

  </head>
    <body>
    <jsp:include page="../common/header.jsp" /> 
	<form id="myForm" action="../../data/excel_export!export.action">
		<input name="beginTime" id="beginTime" type="hidden" value=""/>
		<input name="endTime" id="endTime" type="hidden" value=""/>
		<input name="timeType" id="timeType" type="hidden" value="" />
	</form>
 	<div class="Container">
	    <table class="tabs">
	        <tbody>
	        	<!--tr style="text-align:left">
	                <td>
	                    <ul>
	                        <li><a href="dailySales_search.html">店铺每日销售报表</a></li>
	                    </ul>
	
	                </td>
	            </tr-->
	        </tbody>
	    </table>
	    <div class="inquiry_box">
										<table width="100%" border="0" cellpadding="0" cellspacing="0">
											<tbody align="left" > 
												<tr>
													<td width="20%">
														<strong>请选择以下销售分析报表</strong>
													</td>
													<td><input type="button" class="buttonA" onclick="exportSalesReport()"
															value="生成报表" /></td>
												</tr>
												<tr class="period" id="weekRadio" style="display: ">
													<td width="33%">
															<input id="" type="radio" checked="checked" value="week"
																name="dateType" checked="checked"  onclick="showTimeArea('week')"/>
															销售分析报表-本周
													</td>
													<td width="33%">
															<input id="" type="radio" value="lastWeek"
																name="dateType" onclick="showTimeArea('lastWeek')"/>
															销售分析报表-对比上周
													</td>
													<td width="33%">
															<input id="" type="radio" value="lastYearThisWeek"
																name="dateType" onclick="showTimeArea('lastYearThisWeek')"/>
															销售分析报表-对比去年本周
													</td>
													<td></td>
												</tr>
												<tr class="period" id="monthRadio" style="display: ">
													<td>
															<input id="" type="radio"  value="month"
																name="dateType" onclick="showTimeArea('month')"/>
															销售分析报表-本月
													</td>
													<td>
															<input id="" type="radio" value="lastMonth"
																name="dateType" onclick="showTimeArea('lastMonth')"/>
															销售分析报表-对比上月
													</td>
													<td>
															<input id="" type="radio" value="lastYearThisMonth"
																name="dateType" onclick="showTimeArea('lastYearThisMonth')"/>
															销售分析报表-对比去年本月
													</td>
													<td></td>
												</tr>
												<tr class="period" id="yearRadio" style="display: ">
													<td>
															<input id="" type="radio"  value="year"
																name="dateType" onclick="showTimeArea('year')"/>
															销售分析报表-本年
													</td>
													<td>
															<input id="" type="radio" value="lastYear"
																name="dateType" onclick="showTimeArea('lastYear')"/>
															销售分析报表-对比上年
													</td>
													<td>

													</td>
													<td>

													</td>
												</tr>
												<tr class="period" id="customRadio" style="display: ">
													<td >
															<input id="dateType" type="radio" 
																value="lastCustom" name="dateType" onclick="showTimeArea('lastCustom')"/>
															销售分析报表-自定义时间
													</td>

													<td>
													</td>
													<td>
													</td>
												</tr>
												<tr id="chooseTimeArea">
													<td colspan="3" align="center">
														选择日期：<input name="chooseTime" id="chooseTime" type="text" value="" class="fromDate"/>
														</td>
												</tr>
												<tr id="customTimeArea" style="display:none">
													<td colspan="1">
														开始日期：<input name="chooseBeginTime" id="chooseBeginTime" type="text" value="" class="fromDate"/>
													</td>
													<td colspan="1">
														结束日期：<input name="chooseEndTime" id="chooseEndTime" type="text" value="" class="toDate"/>
													</td>
													<td colspan="2" id="compareYearArea" style="display:none">
														选择对比年份：
														<select id="compareYear" >
															<option value="2008" >2008</option>
															<option value="2009">2009</option>
															<option value="2010">2010</option>
															<option value="2011">2011</option>
															<option value="2012">2012</option>
															<option value="2013" selected>2013</option>
														</select>
													</td>
													
												</tr>
											</tbody>
										</table>
	    </div>
	</div>
    <div class="wrapdown">
        <div class="footer">
            <script type="text/javascript" src="../common/layout/footer.js"></script>
        </div>
    </div>
    </body>
</html>
